package com.jojo.store.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jojo.store.entity.Address;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressMapper extends BaseMapper<Address> {
    Integer countByUid(Integer uid);


    List<Address> findByUid(Integer uid);

    /**
     * 设置对应的用户的所有的isdefault=0；
     */
    @Update("update t_address set is_default=0 where uid=#{uid}")
    Integer upDefault0(Integer uid);
//*自定义分页查询
    IPage<Address> findAll(Page<Address> page,Integer uid);
@Select("delete ")

/**
 * 删除 根据aid;
 */

    Integer deleteByaid(Integer aid);

    /**
     * 根据用户最后一次修改的收货地址的数据；
     * @param uid
     * @return
     */
  @Select("select * from t_address where uid=#{uid} order by modified_time DESC limit 0,1")
  Address findLastmod(Integer uid);


}

